import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wan_android_flutter/pages/home/home_page.dart';
import 'package:wan_android_flutter/pages/knowledge/knowledge_page.dart';
import 'package:wan_android_flutter/pages/personal/personal_page.dart';

import 'hot_key/hot_key_page.dart';

class TabPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _TabPageState();
  }
}

class _TabPageState extends State<TabPage> {
  int currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: SafeArea(
          child: IndexedStack(
        index: currentIndex,
        children: [HomePage(), HotKeyPage(), KnowledgePage(), PerSonalPage()],
      )),
      bottomNavigationBar: Theme(data: Theme.of(context).copyWith(
        splashColor: Colors.transparent,highlightColor: Colors.transparent
      ), child: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        currentIndex: currentIndex,
        items: barItemLists(),
        onTap: (index) {
          currentIndex = index;
          setState(() {});
        },
      ),)
    );
  }

  List<BottomNavigationBarItem> barItemLists() {
    return [
      BottomNavigationBarItem(
          label: "首页",
          activeIcon: Image.asset(
            "assets/images/icon_home_selected.png",
            width: 32.r,
            height: 32.r,
          ),
          icon: Image.asset(
            "assets/images/icon_home_grey.png",
            width: 32.r,
            height: 32.r,
          )),
      BottomNavigationBarItem(
          label: "热点",
          activeIcon: Image.asset(
            "assets/images/icon_hot_key_selected.png",
            width: 32.r,
            height: 32.r,
          ),
          icon: Image.asset(
            "assets/images/icon_hot_key_grey.png",
            width: 32.r,
            height: 32.r,
          )),
      BottomNavigationBarItem(
          label: "体系",
          activeIcon: Image.asset(
            "assets/images/icon_knowledge_selected.png",
            width: 32.r,
            height: 32.r,
          ),
          icon: Image.asset(
            "assets/images/icon_knowledge_grey.png",
            width: 32.r,
            height: 32.r,
          )),
      BottomNavigationBarItem(
          label: "我的",
          activeIcon: Image.asset(
            "assets/images/icon_personal_selected.png",
            width: 32.r,
            height: 32.r,
          ),
          icon: Image.asset(
            "assets/images/icon_personal_grey.png",
            width: 32.r,
            height: 32.r,
          )),
    ];
  }
}
